
local function _countdown(n)
    io.write(n)
    if n == 1 then
        return
    else
        return _countdown(n-1)
    end
end

local function test()
    local num = 0
    io.write = function(v)
        num = num + v
    end

    local val = 5
    _countdown(val)

    local num2 = 0
    for i=1, val do
        num2 =num2 + i
    end
    assert(num2 == num)
end

test()

